package com.example.reggie.common.deploy;

import com.example.reggie.common.table.CodeTable;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * 通用返回结果类,响应结果对象
 * @param <T>
 */
@Data
public class R<T> {
    private Integer code;
    private String msg;
    private T data;
    private Map map =new HashMap();
    public static <T> R<T> success(T obj){
        R<T> r=new R<>();
        r.data=obj;
        r.code= CodeTable.OK;
        return r;
    }

    public static <T> R<T> error(String msg){
        R r=new R();
        r.msg=msg;
        r.code=CodeTable.ERR;
        return r;
    }
    public R<T> add(String key,Object value){
        this.map.put(key,value);
        return this;
    }
}
